<?php

// Check to ensure this file is included in Joomla!

defined('_JEXEC') or die();

jimport( 'joomla.application.component.view');

class OrganizationViewOrganization_edit extends JView
{
	function display($tpl = null)
	{
		global $mainframe;
		
		$db		=& JFactory::getDBO();
		$uri 	=& JFactory::getURI();
		$model	=& $this->getModel();
		$document =& JFactory::getDocument();

		$item	=& $this->get('data');
		$isNew		= ($item->id < 1);
		if ($isNew)
		{
			$item->name = null;
			$item->name_en = null;
			$item->alias = null;
			$item->published = null;
			$item->staffs = null;
			$item->function = null;
			$item->boss = null;
			$item->phone = null;
			$item->email = null;
			$item->address = null;
			$item->people = null;
			$item->equipment = null;
			$item->ability = null;
			$item->foreign = null;
			$item->ideal  = null;
			$item->education  = null;
			$item->file = null;
			$item->catid = 0;
		}
		
		// list
		$lists = array();
		$lists['published'] = JHTML::_('select.booleanlist',  'published', 'class="inputbox"', $item->published );
		
		// danh muc
		$query = 'SELECT c.id AS value, c.name AS text '
			. ' FROM #__ciid_organization_category AS c'
			;
		$db->setQuery( $query );
		$catList[] = JHTML::_('select.option',  '0',JText::_( '--- Chọn Bộ chủ quản ---' ));
		$catList = array_merge( $catList, $db->loadObjectList() );		
		$lists['category'] = JHTML::_('select.genericlist', $catList,'catid', 'class="inputbox" style="width: 250px" ', 'value', 'text',$item->catid);	

		// special
		$query = 'SELECT c.id AS value, c.name AS text '
			. ' FROM #__ciid_organization_special AS c'
			;
		$db->setQuery( $query );
		$special[] = JHTML::_('select.option',  '0',JText::_( '--- Chọn khối ---' ));
		$special = array_merge( $special, $db->loadObjectList() );		
		$lists['special'] = JHTML::_('select.genericlist', $special,'special', 'class="inputbox" style="width: 250px" ', 'value', 'text',$item->special);			
				
		$this->assignRef('item',$item);
		$this->assignRef('lists',$lists);
		
		parent::display($tpl);
	}
	
	function buildList($min,$max,$name,$value)
	{
		//$option = array();
		for ($i=$min; $i<=$max; $i++) {
			$option[] = JHTML::_('select.option', $i,$i);
		}
		$list = JHTML::_('select.genericlist', $option,$name, 'class="inputbox" ', 'value', 'text',$value);		
		return $list;
	}
}
?>